package com.example.hospital_208.service.impl;

import com.example.hospital_208.dao.DoctorDao;
import com.example.hospital_208.po.Doctor;
import com.example.hospital_208.service.DoctorService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DoctorServiceImpl implements DoctorService {

    private final DoctorDao doctorDao;

    public DoctorServiceImpl(DoctorDao doctorDao) {
        this.doctorDao = doctorDao;
    }

    @Override
    public List<Doctor> listDoctors() {
        return doctorDao.findDoctorsWithDepartmentInfo();
    }

    @Override
    public Doctor getDoctorById(String doc_id) {
        return doctorDao.findDoctorWithDepartmentInfoById(doc_id);
    }

    @Override
    public int addDoctor(Doctor doctor) {
        return doctorDao.insertDoctor(doctor);
    }

    @Override
    public int updateDoctor(Doctor doctor) {
        return doctorDao.updateDoctor(doctor);
    }

    @Override
    public int removeDoctor(String doc_id) {
        return doctorDao.deleteDoctorById(doc_id);
    }

    @Override
    public String getDocIdByUserName(String user_name) {
        return doctorDao.findDocIdByUserName(user_name);
    }

    @Override
    public List<Doctor> listDoctorsBySubDepartment(Integer subDepartmentId) {
        return doctorDao.findDoctorsBySubDepartment(subDepartmentId);
    }
}